/**
 * Copyright (c) 2013-Now http://dreamcode123321.com All rights reserved.
 */
package com.jeesite.modules.ab.entity;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;

import com.jeesite.common.entity.TreeEntity;
import com.jeesite.common.utils.excel.annotation.ExcelField;
import com.jeesite.common.utils.excel.annotation.ExcelFields;
import com.jeesite.common.utils.excel.fieldtype.CompanyType;
import com.jeesite.common.utils.excel.fieldtype.OfficeType;
import com.jeesite.modules.sys.entity.Area;
import com.jeesite.modules.sys.entity.Company;
import com.jeesite.modules.sys.entity.Employee;
import com.jeesite.modules.sys.entity.Office;
import org.hibernate.validator.constraints.Length;
import java.util.Date;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
import com.fasterxml.jackson.annotation.JsonFormat;

import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;

/**
 * ab_tempEntity
 * @author dreamcode
 * @version 2020-06-20
 */
@Table(name="ab_temp", alias="a", columns={
		@Column(name="id", attrName="id", label="序号", isPK=true),
		@Column(name="name", attrName="name", label="用户名", queryType=QueryType.LIKE),
		@Column(name="office_id", attrName="officeId", label="供热公司部门"),
		@Column(name="area_id", attrName="areaId", label="行政区域"),
		@Column(name="floor", attrName="floor", label="小区楼宇"),
		@Column(name="temp_id", attrName="tempId", label="测温ID", isQuery=false),
		@Column(name="now_temp", attrName="nowTemp", label="当前温度", isQuery=false),
		@Column(name="out_temp", attrName="outTemp", label="室外温度", isQuery=false),
		@Column(name="upload_time", attrName="uploadTime", label="上传时间", isQuery=false),
		@Column(name="address", attrName="address", label="地址", isQuery=false),
		@Column(name="areas", attrName="areas", label="面积", isQuery=false),
	}, joinTable={
		@JoinTable(type=Type.LEFT_JOIN, entity=Office.class, alias="o",
				on="o.office_code=a.office_id", attrName="office",
				columns={
						@Column(includeEntity=DataEntity.class),
						@Column(includeEntity= TreeEntity.class),
						@Column(name="office_code", label="机构编码", isPK=true),
						@Column(name="view_code", 	label="机构代码"),
						@Column(name="office_name", label="机构名称", isQuery=false),
						@Column(name="full_name", 	label="机构全称"),
						@Column(name="office_type", label="机构类型"),
						@Column(name="leader", 		label="负责人"),
						@Column(name="phone", 		label="电话"),
						@Column(name="address", 	label="联系地址"),
						@Column(name="zip_code", 	label="邮政编码"),
						@Column(name="email", 		label="邮箱"),
				}),
		@JoinTable(type=Type.LEFT_JOIN, entity= Company.class, alias="c",
				on="c.company_code=a.company_code", attrName="company",
				columns={
						@Column(includeEntity=DataEntity.class),
						@Column(includeEntity=TreeEntity.class),
						@Column(name="company_code", label="公司编码", isPK=true),
						@Column(name="view_code", 	label="公司代码"),
						@Column(name="company_name", label="公司名称", isQuery=false),
						@Column(name="full_name", 	label="公司全称"),
				}),
		@JoinTable(type=Type.LEFT_JOIN, entity=Area.class, alias="ar",
				on="ar.area_code = a.area_id", attrName="area",
				columns={
						@Column(name="area_code", label="区域代码", isPK=true),
						@Column(name="area_name", label="区域名称", isQuery=false),
						@Column(name="area_type", label="区域类型"),
				})
	}, orderBy="a.id DESC"
)
public class AbTemp extends DataEntity<AbTemp> {
	@Valid
	@ExcelFields({
			@ExcelField(title="用户名", attrName="name", align= ExcelField.Align.CENTER, sort=10),
			@ExcelField(title="供热公司部门", attrName="office.officeName", align = ExcelField.Align.CENTER, sort=20, fieldType=Office.class),
			@ExcelField(title="行政区域", attrName="area.areaName", align= ExcelField.Align.CENTER, sort=30, fieldType=Area.class),
			@ExcelField(title="小区楼宇", attrName="floor", align= ExcelField.Align.CENTER, sort=40),
			@ExcelField(title="测温ID", attrName="nowTemp", align= ExcelField.Align.LEFT, sort=50),
			@ExcelField(title="当前温度（℃）", attrName="nowTemp", align= ExcelField.Align.CENTER, sort=60),
			@ExcelField(title="室外温度（℃）", attrName="outTemp", align= ExcelField.Align.CENTER, sort=70),
			@ExcelField(title="地址", attrName="address", width=20*256, align= ExcelField.Align.CENTER, sort=75),
			@ExcelField(title="面积（㎡）", attrName="areas", align= ExcelField.Align.CENTER, sort=80),
			@ExcelField(title="上传时间", attrName="uploadTime", width=20*256, align= ExcelField.Align.CENTER, sort=900, type=ExcelField.Type.EXPORT, dataFormat="yyyy-MM-dd HH:mm"),
	})
	
	private static final long serialVersionUID = 1L;
	private String name;		// 用户名
	private Office office;		// 供热公司部门
	private Area area;		// 行政区域
	private String floor;		// 小区楼宇
	private String tempId;		// 测温ID
	private Double nowTemp;		// 当前温度
	private Double outTemp;		// 室外温度
	private Date uploadTime;		// 上传时间
	private String address;		// 地址
	private Double areas;		// 面积
	
	public AbTemp() {
		this(null);
	}

	public AbTemp(String id){
		super(id);
	}
	
	@NotBlank(message="用户名不能为空")
	@Length(min=0, max=255, message="用户名长度不能超过 255 个字符")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Office getOffice() {
		return office;
	}

	public void setOffice(Office office) {
		this.office = office;
	}

	public Area getArea() {
		return area;
	}

	public void setArea(Area area) {
		this.area = area;
	}

	@Length(min=0, max=64, message="小区楼宇长度不能超过 64 个字符")
	public String getFloor() {
		return floor;
	}

	public void setFloor(String floor) {
		this.floor = floor;
	}
	
	@Length(min=0, max=64, message="测温ID长度不能超过 64 个字符")
	public String getTempId() {
		return tempId;
	}

	public void setTempId(String tempId) {
		this.tempId = tempId;
	}
	
	public Double getNowTemp() {
		return nowTemp;
	}

	public void setNowTemp(Double nowTemp) {
		this.nowTemp = nowTemp;
	}
	
	public Double getOutTemp() {
		return outTemp;
	}

	public void setOutTemp(Double outTemp) {
		this.outTemp = outTemp;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date getUploadTime() {
		return uploadTime;
	}

	public void setUploadTime(Date uploadTime) {
		this.uploadTime = uploadTime;
	}
	
	@Length(min=0, max=255, message="地址长度不能超过 255 个字符")
	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}
	
	public Double getAreas() {
		return areas;
	}

	public void setAreas(Double areas) {
		this.areas = areas;
	}
	
}